Skip to main content

Execute Macro

AutomatR.Excel.Activities.ExecuteMacro

The "Execute Macro" activity in AutomatR is part of the Excel activities package, designed to execute a specified macro within an Excel workbook. This activity is particularly useful for automating complex tasks in Excel that are defined by macros.

Properties

NameDescription
Input
Enter Method ParametersEnter the parameters/arguments in the macro code as an Enumerable object list.
Macro nameEnter the macro name to be executed for an Excel workbook. String variables containing the macro name.
Misc
Display NameThe display name of the activity. A display name is automatically generated when you indicate a target.
Optional
DelaySpecifies the amount of time (in seconds) to wait before executing the "Execute Macro" activity. This can be useful for handling synchronization issues. Integer variables containing the delay duration. Example: If the amount of time is 1000 milliseconds or 1 sec, i.e., 1.

How to use:

  1. Drag and drop the "Execute Macro" activity onto the workflow.
  2. Configure the properties by specifying the macro name and, optionally, providing method parameters.
  3. Optionally, configure the delay.
  4. Execute the workflow to run the specified macro within the Excel workbook.

Example: Consider an example where the "Execute Macro" activity is used to execute a macro named "MyMacro" with parameters:

Execute Macro:
Macroname: "MyMacro"
Enter Method Parameters: {param1, param2, param3}
Delay: 2

In this example, the activity executes the "MyMacro" macro within the Excel workbook. The parameters "param1," "param2," and "param3" are provided to the macro. The execution is delayed by 2 seconds as specified in the delay property.

Note: Ensure that the "Execute Macro" activity is placed within an "Excel Root" activity to establish the Excel context for execution.